//控制单位放置静态武器
params ["_unit"];

private ["_type", "_static","_player", "_veh", "_group"];

_group = group _unit;
_type = typeOf _unit;

if(!(_type in asu_support)) exitWith{};

_static = "";


if(_type find "_MG_F" >= 0) then
{
	_static =  selectRandom asu_hmg;
}
else 
{
	if(_type find "_GMG_F" >= 0) then
	{
		_static =  selectRandom asu_gmg;
	}
	else 
	{
		if(_type find "_Mort_F" >= 0) then
		{
			_static = selectRandom asu_mort;
		};
	};
};



if(_static isEqualTo "") exitWith{}; 


private _end = false;
while{!_end}do
{
	sleep 15;
	if((isNull _unit) || (!alive _unit)) exitWith {};
	
	if(simulationEnabled _unit) then{
		
		_player = [_unit, 800] call fn_getPlayerAttack;
		
		if !(isNull _player) exitWith
		{
			_end = true;
			[_unit,"AinvPknlMstpSnonWnonDnon_Putdown_AmovPknlMstpSnonWnonDnon"] remoteExec ["playMoveNow",0];
			sleep 5;
			_veh = _static createVehicle (getPos _unit);
			_veh setDir (_veh getDir _player);//朝向玩家
			_unit assignAsGunner _veh;
			//[_unit] orderGetIn true;
			_unit moveInGunner _veh;
			removeBackpackGlobal _unit;
			
			//死亡事件
			[_unit] call fn_eventSupport;
		};
	};
};
